<template>
  <div class="container2">
     <topSearch :form='form' :showInitiate='true' :showAdd="false" @handleClick="handleClick" @searchlist='searchlist' @resetform='resetform'></topSearch>
    <el-row>
      <tableItem
        :tabData="tabData"
        @changepage="changepage"
        @changepageTotal="changepageTotal"
        @lookItem="lookItem"
        @approval="approval"
        @editItem="editItem"
      ></tableItem>
    </el-row>
    <subdialog
      :isshowDialog="isshowDialog"
      :dialogTitle="dialogTitle"
      :formType="formtype"
      @confirm="confirm"
      @closedialog="closedialog"
      :dialogdata="dialogdata"
    ></subdialog>
    <approvalDialog
      :isshowDialog="isshowDialogApp"
      :dialogTitle="dialogTitleApp"
      @confirm="confirm"
      @closedialog="closedialog"
      :dialogdata="dialogdataApp"
      :updateUserOptions="updateUserOptions"
    ></approvalDialog>
  </div>
</template>

<script type="text/javascript">
import tableItem from "./components/table";
import subdialog from "./components/dialog";
import approvalDialog from "./components/approvalDialog";
import topSearch from "@/components/topSearch";
import { school, schoolDetail } from "@/api/institutional";
import { userOption } from "@/api/examplace";
export default {
  data() {
    return {
      page: 1,
      rows: 10,
      tabData: {},
      form: {},
      activeName: "spz",
      currentIndex: 0,
      isshowDialog: false,
      dialogTitle: "查看",
      formtype: 0,
      dialogdata: null,
      dialogdataApp: null,
      isshowDialogApp: false,
      dialogTitleApp: "移交",
      updateUserOptions:[]
    };
  },
  components: {
    tableItem,
    subdialog,
    topSearch,
    approvalDialog
  },
  methods: {
    changepage(val) {
      this.page = val;
      this.getData();
    },
    changepageTotal(val) {
      this.rows = val;
      this.getData();
    },
    searchlist() {
       this.page= 1,
      this.getData();
    },
    resetform() {

      this.getData();
    },
    //获取列表
    async getData(val) {
      let params = {
        page: this.page,
        rows: this.rows,
      };
      if (this.form.keyWord) {
        params.keyword = this.form.keyWord;
      }
      if (this.currentIndex != 0) {
        params._type = this.currentIndex;
      }
      let data = await school(params);
      let datainfo = data.data;
      this.tabData = datainfo;
    },
    handleClick(tab, event) {
      this.currentIndex = tab.index;
      this.getData();
    },
    //详情
    async getplatformDetail(id) {
      let data = await schoolDetail({ id: id });
      this.dialogdata = data.data;
      console.log(data);
    },
    //查看
    lookItem(val) {
      
      this.isshowDialog = true;
      this.dialogTitle = "查看";
      this.formtype = 0;
      this.getplatformDetail(val.id);
    },
    //移交
    approval(val) {
      this.isshowDialogApp = true;
      this.dialogTitle = "移交";
      this.formtype = 0;
      this.dialogdataApp=val
    },
    //审核
    editItem(val) {
      
      this.isshowDialog = true;
      this.dialogTitle = "审核";
      this.formtype = 1;
      this.getplatformDetail(val.id);
      console.log(this.formtype);
    },
    //提交成功
    confirm() {
      this.isshowDialog = false;
      this.isshowDialogApp = false;
      this.getData();
    },
    closedialog() {
      this.isshowDialog = false;
      this.isshowDialogApp = false;
    },
     //更新人下拉
    async getuserOption() {
      let data = await userOption();
      this.updateUserOptions = data.data;
    },
  },
  created() {
    this.getData();
    this.getuserOption();
  },
};
</script>

<style lang="scss" scoped>
</style>
